<?php
namespace app\api\model\msg;

use think\Model;
use think\Db;
class Msgmodel extends Model{
    /**
     *  发送消息
     */
    public function sendMsg($data){
        $data['create_time'] = date('Y-m-d H:i:s');
        $res = db('lj_chat_record')->insert($data);
        if($res){
            return $res;
        }else{
            return false;
        }
    }

    /**
     * 获取未发送的消息
     */
    public function getNoSendMsg($uid){
        $where = [
            'receive_uid' => $uid,
            'status' => 2
        ];
        $res = db('lj_chat_record')->where('receive_uid',$uid)->select();
        if($res){
            return $res;
        }else{
            return false;
        }
    }

    /**
     * 修改消息发送状态
     */
    public function changeSendMsgStatus($id){
        db('lj_chat_record')->where('id',$id)->update(['status'=>1]);
    }

}